package boardgamer.common.client;

import boardgamer.common.client.animation.Screen;

import java.util.Stack;

/**
 * @author garysoed
 */
public class HistoryStack {

  private Stack<Screen> screens;

  public HistoryStack() {
    this.screens = new Stack<Screen>();
  }

  public void setCurrentScreen(Screen screen) {
    screens.push(screen);
    screen.onOpen();
  }

  public Screen getCurrentScreen() {
    return screens.peek();
  }

  public void back() {
    screens.pop();
  }

  public void clearHistory() {
    screens.clear();
  }

  public boolean isHistoryEmpty() {
    return screens.size() <= 1;
  }
}
